﻿@model MvcMasterPage.Models.Review
<style>
    li {
        list-style-type: none;
    }
</style>
<script type="text/javascript">
    function submitForm() {
        $.ajax({
            type: 'POST',
            url: '@Url.Action("AJAXReview", "Common")',
            data: $("#form1").serialize(),
            success: function (data) {
                if (data.res)
                    alert("提交成功");
                else
                    alert("提交失败，失败信息为：" + data.info);
            }
        })
    }

    var Review = {
        IsChecked: true,
        Dialog: function (msg) {
            Boxy.alert(msg, null, { title: "提示信息" });
        },
        Check: function () {
            if ($("#Title").val().length == 0) {
                $("#Title").after("<p class='errMsg' style='display:block;color:Red;font-size:14px;padding-left:70px;'>请填写名称</p>");
                this.IsChecked = false;
                return;
            }
            if ($("#Content").val().length == 0) {
                $("#Content").after("<p class='errMsg' style='color:Red;font-size:14px;padding-left:70px;'>请填写内容</p>");
                this.IsChecked = false;
                return;
            }
            this.IsChecked = true;
        },
        Submit: function (callback) {
            this.Init();
            this.Check();
            if (this.IsChecked) {
                callback();
            }
        },
        Init: function () {
            $("form").find("p[class=errMsg]").remove();
        }
    }
</script>
@using (Html.BeginForm("Review", "Common", FormMethod.Post, new
{
    id = "form1"
}))
{
    <fieldset>
        <legend>评论 </legend>
        <ul>@Html.ValidationSummary(true)
            @Html.HiddenFor(i => i.ObjID)
            @Html.HiddenFor(i => i.ObjType)
            <li>标题：@Html.TextBoxFor(i => i.Title)</li>
            <li>内容：@Html.TextAreaFor(i => i.Content)</li>
        </ul>
    </fieldset>
    <input type="button" onclick="Review.Submit(submitForm)" value="提交" />
}